<?php
include '../include/init.php';

$needid=$_POST['needid'];
$type=$_POST['type'];

if($type=="intro_basic")
{
	$user=new userModel();
	$bc=$user->getinfo($needid);
	if($bc)
	{
		echo json_encode($bc);
	}
	else
	{
		echo json_encode('no');
	}
	exit;
}
else if($type=="intro_detail")
{
	$user=new userModel();
	$dts=$user->getdetail($needid);
	if($dts)
	{
		echo json_encode($dts);
	}
	else
	{
		echo json_encode('no');
	}
	exit;
}
else if($type=='update')
{
	$detail=trim($_POST['detail']);
	$basic=trim($_POST['basic']);
	if($detail==''&&$basic=='')
	{
		die(json_encode('no'));
	}
	$user=new userModel();
	
	$b=true;
	$d=true;
	if($detail!='')
	{
		$detail=trim($detail,';');
		$detail = str_replace(array('-',';'),array('"=>"','","'),'array("'.$detail.'")');
		eval("\$detail"." = $detail;");
		$d=$user->setdetail($detail,$needid);
	}
	
	if($basic!='')
	{
		$basic=trim($basic,';');
		$basic = str_replace(array('-',';'),array('"=>"','","'),'array("'.$basic.'")');
		eval("\$basic"." = $basic;");
		$b=$user->setbasic($basic,$needid);
	}

	if($b&&$d)
	{
		echo json_encode('ok');
	}
	else
	{
		echo json_encode('no');
	}
	exit;
}
else if($type=='setsign')
{
	$sign=trim($_POST['str']);
	$user=new userModel();
	if($user->modify($needid,'sign',$sign))
	{
		die(json_encode('ok'));
	}
	die(json_encode('no'));
	
}
else if($type=='gethishead')
{
	$user=new userModel();
	if($his=$user->getone($needid,'imghead_history','ownid','usr_detail'))
	{
		die(json_encode($his));
	}
	die(json_encode('no'));
}